﻿Namespace Equipment

    Module mEquipment

        Private Structure EquipmentSlotDesc
            Dim rRect As Rectangle
            Dim itemtype As EvoLib.Protocol.ItemType
            Dim slottype As EvoLib.Protocol.ItemLocation
            Dim item As GUI.MirItemDesc
            Dim isSet As Boolean
        End Structure

        Dim EquipSlots(12) As EquipmentSlotDesc
        Dim HoverSlot As Integer = -1

        Private WithEvents EquipmentWindow As GUI.MirWindow
        'TODO: make private
        Public WithEvents HideEquip As GUI.MirButton
        'Private WithEvents HideEquip As GUI.MirButton
        
        Private IsVisible As Boolean

        Public Sub Init()

            EquipmentWindow = New GUI.MirWindow("EquipmentWindow", , , 327, 466, True)
            'Windows.AddWindow(EquipmentWindow, Windows.WindowType.Normal)

            HideEquip = New GUI.MirButton(EquipmentWindow, "HideEquip", 291, 18, 0.0F, ImgLibs.GameInter, 0, 3036, 3036)

            EquipSlots(0).rRect = New Rectangle(13, 168, 36, 36)
            EquipSlots(0).itemtype = EvoLib.Protocol.ItemType.Bracer
            EquipSlots(0).slottype = EvoLib.Protocol.ItemLocation.EquipLeftBracer

            EquipSlots(1).rRect = New Rectangle(175, 168, 36, 36)
            EquipSlots(1).itemtype = EvoLib.Protocol.ItemType.Bracer
            EquipSlots(1).slottype = EvoLib.Protocol.ItemLocation.EquipRightBracer

            EquipSlots(2).rRect = New Rectangle(175, 128, 36, 36)
            EquipSlots(2).itemtype = EvoLib.Protocol.ItemType.Necklace
            EquipSlots(2).slottype = EvoLib.Protocol.ItemLocation.EquipNecklace

            EquipSlots(3).rRect = New Rectangle(13, 208, 36, 36)
            EquipSlots(3).itemtype = EvoLib.Protocol.ItemType.Ring
            EquipSlots(3).slottype = EvoLib.Protocol.ItemLocation.EquipLeftRing

            EquipSlots(4).rRect = New Rectangle(175, 208, 36, 36)
            EquipSlots(4).itemtype = EvoLib.Protocol.ItemType.Ring
            EquipSlots(4).slottype = EvoLib.Protocol.ItemLocation.EquipRightRing

            EquipSlots(5).rRect = New Rectangle(175, 248, 36, 72)
            EquipSlots(5).itemtype = EvoLib.Protocol.ItemType.Talisman
            EquipSlots(5).slottype = EvoLib.Protocol.ItemLocation.EquipTalisman

            EquipSlots(6).rRect = New Rectangle(95, 284, 36, 36)
            EquipSlots(6).itemtype = EvoLib.Protocol.ItemType.Torch
            EquipSlots(6).slottype = EvoLib.Protocol.ItemLocation.EquipTorch

            EquipSlots(7).rRect = New Rectangle(13, 248, 36, 72)
            EquipSlots(7).itemtype = EvoLib.Protocol.ItemType.Shoes
            EquipSlots(7).slottype = EvoLib.Protocol.ItemLocation.EquipShoes

            EquipSlots(8).rRect = New Rectangle(13, 168, 36, 36)
            EquipSlots(8).itemtype = EvoLib.Protocol.ItemType.Trinket
            EquipSlots(8).slottype = EvoLib.Protocol.ItemLocation.EquipTrinket

            EquipSlots(9).rRect = New Rectangle(13, 168, 36, 36)
            EquipSlots(9).itemtype = EvoLib.Protocol.ItemType.HorseArmor
            EquipSlots(9).slottype = EvoLib.Protocol.ItemLocation.EquipHorseArmor

            EquipSlots(10).rRect = New Rectangle(83, 122, 70, 150)
            If Player.PlayerSex = EvoLib.Protocol.Gender.Male Then
                EquipSlots(10).itemtype = EvoLib.Protocol.ItemType.MArmor
            Else
                EquipSlots(10).itemtype = EvoLib.Protocol.ItemType.FArmor
            End If
            EquipSlots(10).slottype = EvoLib.Protocol.ItemLocation.EquipArmor

            EquipSlots(11).rRect = New Rectangle(96, 79, 35, 43)
            EquipSlots(11).itemtype = EvoLib.Protocol.ItemType.Helmet
            EquipSlots(11).slottype = EvoLib.Protocol.ItemLocation.EquipHelmet

            EquipSlots(12).rRect = New Rectangle(52, 68, 43, 119)
            EquipSlots(12).itemtype = EvoLib.Protocol.ItemType.Weapon
            EquipSlots(12).slottype = EvoLib.Protocol.ItemLocation.EquipWeapon

        End Sub

        Public Sub Shutdown()

            EquipmentWindow.Destory()

        End Sub

        Public Sub EquipItem(ByRef item As EvoLib.Protocol.ItemInfo, ByRef slot As EvoLib.Protocol.ItemLocation)

            For i As Integer = 0 To 12
                If EquipSlots(i).slottype = slot Then
                    If Not EquipSlots(i).isSet Then

                    Dim tmp As GUI.MirItemDesc
                    tmp.info = item
                    tmp.alphacol = Color.FromArgb(item.INT_ALPHACOL)
                    EquipSlots(i).item = tmp
                    EquipSlots(i).isSet = True

                    Select Case slot

                        Case EvoLib.Protocol.ItemLocation.EquipArmor
                            Player.ShapeInfo.INT_ARMORSHAPE = item.Base.INT_SHAPE
                            Player.ShapeInfo.INT_ARMORCOL = item.INT_ALPHACOL
                            Player.CalcAnim(True, True)

                        Case EvoLib.Protocol.ItemLocation.EquipHelmet
                            Player.ShapeInfo.INT_HEADSHAPE = item.Base.INT_SHAPE
                            Player.CalcAnim(True, True)

                        Case EvoLib.Protocol.ItemLocation.EquipWeapon
                            Player.ShapeInfo.INT_WEAPONSHAPE = item.Base.INT_SHAPE
                            Player.CalcAnim(True, True)

                        Case EvoLib.Protocol.ItemLocation.EquipTorch
                            Player.ShapeInfo.BOOL_HASLIGHT = True

                    End Select


                End If
                End If
            Next

        End Sub

        Public Sub UnequipItem(itemid As Long)

            For i As Integer = 0 To 12

                If EquipSlots(i).item.info.INT_ID = itemid Then

                    'If EquipSlots(i).slottype = EvoLib.Protocol.mProtocol.ItemLocation.EquipTorch or EquipSlots(i).slottype = EvoLib.Protocol.mProtocol.ItemLocation.EquipWeapon
                    'HandWeight -= EquipSlots(i).item.info.Base.INT2_WEIGHT
                    'Else
                    'BodyWeight -= EquipSlots(i).item.info.Base.INT2_WEIGHT
                    'End If

                    EquipSlots(i).isSet = False
                End If

            Next

        End Sub

        Private Sub EquipmentWindow_DrawWindow(ByRef mode As Globals.mGlobalVars.DrawingMode, ByRef x As Integer, ByRef y As Integer, ByRef z As Single) Handles EquipmentWindow.DrawWindow

            If mode = Globals.DrawingMode.Normal Then
                'draw window
                Libs.GameInter.Image(181).Draw(x - 92, y - 23, z)

                'draw male or female doll
                Dim tempimgindex As Integer
                If Player.PlayerSex = EvoLib.Protocol.Gender.Male Then
                    tempimgindex = 1
                Else
                    tempimgindex = 2
                End If
                With Libs.ProgUse.Image(tempimgindex)
                    .Draw(x + 88 + .Header.OffsetX, y + 220 + .Header.OffsetY, z)
                End With

                'draw slot hover highlights
                If GUI.MouseDragItem.HasMouseDragItem Then
                    If HoverSlot >= 0 And HoverSlot < 10 Then
                        If Mouse.XCoord >= EquipmentWindow.mPosX + EquipSlots(HoverSlot).rRect.Left And Mouse.XCoord < EquipmentWindow.mPosX + EquipSlots(HoverSlot).rRect.Right Then
                            If Mouse.YCoord >= EquipmentWindow.mPosY + EquipSlots(HoverSlot).rRect.Top And Mouse.YCoord < EquipmentWindow.mPosY + EquipSlots(HoverSlot).rRect.Bottom Then
                                Select Case EquipSlots(HoverSlot).itemtype
                                    Case EvoLib.Protocol.ItemType.Bracer
                                        tempimgindex = 195
                                    Case EvoLib.Protocol.ItemType.Ring
                                        tempimgindex = 191
                                    Case EvoLib.Protocol.ItemType.Necklace
                                        tempimgindex = 192
                                    Case EvoLib.Protocol.ItemType.Torch
                                        tempimgindex = 194
                                    Case EvoLib.Protocol.ItemType.Shoes
                                        tempimgindex = 196
                                    Case EvoLib.Protocol.ItemType.Talisman
                                        tempimgindex = 197
                                End Select

                                Libs.GameInter.Image(tempimgindex).Draw(x + EquipSlots(HoverSlot).rRect.Left, y + EquipSlots(HoverSlot).rRect.Top, z)

                            End If
                        End If
                    End If
                End If

                For i As Integer = 0 To 7
                    If EquipSlots(i).isSet Then
                        With EquipSlots(i).item.info.Base
                            Libs.Inventory.Image(.INT_LOOKS).Draw(x + EquipSlots(i).rRect.Left + ((EquipSlots(i).rRect.Width / 2) - (Libs.Inventory.Image(.INT_LOOKS).Header.Width / 2)), _
                                                                      y + EquipSlots(i).rRect.Top + ((EquipSlots(i).rRect.Height / 2) - (Libs.Inventory.Image(.INT_LOOKS).Header.Height / 2)), z)
                        End With
                    End If
                Next
                If EquipSlots(12).isSet Then
                    With EquipSlots(12).item.info.Base
                        Libs.Equip.Image(.INT_LOOKS).Draw(x + 88 + Libs.Equip.Image(.INT_LOOKS).Header.OffsetX, y + 220 + Libs.Equip.Image(.INT_LOOKS).Header.OffsetY, z)
                    End With
                End If

            End If

            If mode = Globals.DrawingMode.Normal Or mode = Globals.DrawingMode.Tinted Then

                If EquipSlots(10).isSet Then
                    With EquipSlots(10).item.info
                        If mode = Globals.DrawingMode.Normal Then
                            Libs.Equip.Image(.Base.INT_LOOKS).Draw(x + 88 + Libs.Equip.Image(.Base.INT_LOOKS).Header.OffsetX, y + 220 + Libs.Equip.Image(.Base.INT_LOOKS).Header.OffsetY, z)
                        Else
                            DirectX.GameSprite.Begin(Microsoft.DirectX.Direct3D.SpriteFlags.AlphaBlend)
                            Engine.SetDrawModeTinted(1.0, Color.FromArgb(.INT_ALPHACOL))
                            Libs.Equip.Image(.Base.INT_LOOKS).DrawAlpha(x + 88 + Libs.Equip.Image(.Base.INT_LOOKS).Header.OffsetX, y + 220 + Libs.Equip.Image(.Base.INT_LOOKS).Header.OffsetY, z)
                            DirectX.GameSprite.End()
                        End If
                    End With
                End If

                If Not EquipSlots(11).isSet Then
                    If Player.ShapeInfo.INT_HAIRSHAPE <> 22 Then
                        Dim hairimg As Integer

                        If Player.PlayerSex = EvoLib.Protocol.Gender.Male Then
                            If Player.ShapeInfo.INT_HAIRSHAPE < 11 Then
                                hairimg = 61 + Player.ShapeInfo.INT_HAIRSHAPE
                            Else
                                hairimg = 1101 + Player.ShapeInfo.INT_HAIRSHAPE - 11
                            End If
                        Else
                            If Player.ShapeInfo.INT_HAIRSHAPE < 11 Then
                                hairimg = 81 + Player.ShapeInfo.INT_HAIRSHAPE
                            Else
                                hairimg = 1121 + Player.ShapeInfo.INT_HAIRSHAPE - 11
                            End If
                        End If

                        With Libs.ProgUse.Image(hairimg)
                            If mode = Globals.DrawingMode.Normal Then
                                .Draw(x + 88 + .Header.OffsetX, y + 220 + .Header.OffsetY, z)
                            Else
                                DirectX.GameSprite.Begin(Microsoft.DirectX.Direct3D.SpriteFlags.AlphaBlend)
                                Engine.SetDrawModeTinted(1.0, Color.FromArgb(Player.ShapeInfo.INT_HAIRCOL))
                                .DrawAlpha(x + 88 + .Header.OffsetX, y + 220 + .Header.OffsetY, z)
                                DirectX.GameSprite.End()
                            End If
                        End With
                    End If
                Else
                    If mode = Globals.DrawingMode.Normal Then
                        With EquipSlots(11).item.info.Base
                            Libs.Equip.Image(.INT_LOOKS).Draw(x + 88 + Libs.Equip.Image(.INT_LOOKS).Header.OffsetX, y + 220 + Libs.Equip.Image(.INT_LOOKS).Header.OffsetY, z)
                        End With
                    ElseIf mode = Globals.DrawingMode.Tinted Then
                        DirectX.GameSprite.Begin(Microsoft.DirectX.Direct3D.SpriteFlags.AlphaBlend)
                        With EquipSlots(11).item.info
                            Engine.SetDrawModeTinted(1.0, Color.FromArgb(.INT_ALPHACOL))
                            Libs.Equip.Image(.Base.INT_LOOKS).DrawAlpha(x + 88 + Libs.Equip.Image(.Base.INT_LOOKS).Header.OffsetX, y + 220 + Libs.Equip.Image(.Base.INT_LOOKS).Header.OffsetY, z)
                        End With
                        DirectX.GameSprite.End()
                    End If
                End If

            End If

            If mode = Globals.DrawingMode.Text Then

                'Current player level
                DirectX.ProFont9.DrawNormalText(Player.PlayerLevel, x + 250, y + 112, Color.Red, z)
                'Exp in %
                DirectX.ProFont9.DrawNormalText(FormatPercent(Player.CurrentXP / Player.NextLevelXP, 2), x + 250, y + 136, Color.Red, z)

                'HP & MP Display
                DirectX.ProFont9.DrawNormalText(Player.VitalPoints.HP & "/" & Player.VitalPoints.MAXHP, x + 250, y + 160, Color.White, z)
                DirectX.ProFont9.DrawNormalText(Player.VitalPoints.MP & "/" & Player.VitalPoints.MAXMP, x + 250, y + 184, Color.White, z)

                'Bag Weight
                DirectX.ProFont9.DrawNormalText(Player.PlayerWeight.INT4_BAGWEIGHT & "/" & Player.Stats.INT2_MAX_WEIGHT, x + 250, y + 208, Color.White, z)
                'Body Weightht 
                DirectX.ProFont9.DrawNormalText(Player.PlayerWeight.INT4_WEARWEIGHT & "/" & Player.Stats.INT2_MAX_WEARWEIGHT, x + 250, y + 232, Color.White, z)
                'Hand Weight
                DirectX.ProFont9.DrawNormalText(Player.PlayerWeight.INT4_HANDWEIGHT & "/" & Player.Stats.INT2_MAX_HANDWEIGHT, x + 250, y + 256, Color.White, z)
                DirectX.ProFont9.DrawNormalText("+" & Player.Stats.INT1_AGILITY, x + 250, y + 280, Color.White, z)
                DirectX.ProFont9.DrawNormalText("+" & Player.Stats.INT1_ACCURACY, x + 250, y + 304, Color.White, z)


                'DC
                DirectX.ProFont9.DrawNormalText("DC " & Player.Stats.INT2_MIN_DC & "-" & Player.Stats.INT2_MAX_DC, x + 14, y + 341, Color.White, z)
                'AC
                DirectX.ProFont9.DrawNormalText("AC " & Player.Stats.INT2_MIN_AC & "-" & Player.Stats.INT2_MAX_AC, x + 117, y + 341, Color.White, z)

                'MC
                DirectX.ProFont9.DrawNormalText("MC " & Player.Stats.INT2_MIN_MC & "-" & Player.Stats.INT2_MAX_MC, x + 14, y + 366, Color.White, z)
                'SC
                DirectX.ProFont9.DrawNormalText("SC " & Player.Stats.INT2_MIN_SC & "-" & Player.Stats.INT2_MAX_SC, x + 117, y + 366, Color.White, z)
                'MAC
                DirectX.ProFont9.DrawNormalText("AMC " & Player.Stats.INT2_MIN_MAC & "-" & Player.Stats.INT2_MAX_MAC, x + 220, y + 366, Color.White, z)

                'Element Labels
                ' Attack
                DirectX.ProFont9.DrawNormalText("Attack", x + 14, y + 389, Color.White, z)
                ' Adv
                DirectX.ProFont9.DrawNormalText("Adv", x + 14, y + 414, Color.White, z)
                ' Dis
                DirectX.ProFont9.DrawNormalText("Dis", x + 14, y + 439, Color.White, z)

                DirectX.ProFont9.DrawNormalText(Player.PlayerName, x + 162 - (DirectX.ProFont9.GetNormalTextWidth(Player.PlayerName) / 2), y + 20, Color.White, z)
                DirectX.ProFont9.DrawNormalText(Player.GuildName, x + 162 - (DirectX.ProFont9.GetNormalTextWidth(Player.GuildName) / 2), y + 32, Color.White, z)
                DirectX.ProFont9.DrawNormalText(Player.GuildTitle, x + 162 - (DirectX.ProFont9.GetNormalTextWidth(Player.GuildTitle) / 2), y + 44, Color.White, z)

                'TODO: Spouse name
                DirectX.ProFont9.DrawNormalText(Player.SpouseName, x + 162 - (DirectX.ProFont9.GetNormalTextWidth(Player.SpouseName) / 2), y + 68, Color.White, z)

            End If

            If mode = Globals.DrawingMode.Normal Or Globals.DrawingMode.Text Then

                With Player.Stats
                    'Elements

                    'fire attack
                    If .INT2_ELEMC_FIRE <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(182).Draw(x + 63, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_FIRE, x + 63, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_FIRE <> 0 Then

                        If .INT2_ELEMAC_FIRE > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(182).Draw(x + 63, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_FIRE, x + 63, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(182).Draw(x + 63, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_FIRE, x + 63, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                    'Ice
                    If .INT2_ELEMC_ICE <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(183).Draw(x + 100, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_ICE, x + 100, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_ICE <> 0 Then

                        If .INT2_ELEMAC_ICE > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(183).Draw(x + 100, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_ICE, x + 100, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(183).Draw(x + 100, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_ICE, x + 100, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                    'Lightning
                    If .INT2_ELEMC_LIGHT <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(184).Draw(x + 137, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_LIGHT, x + 137, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_LIGHT <> 0 Then

                        If .INT2_ELEMAC_LIGHT > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(184).Draw(x + 137, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_LIGHT, x + 137, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(184).Draw(x + 137, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_LIGHT, x + 137, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                    'wind
                    If .INT2_ELEMC_WIND <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(185).Draw(x + 174, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_WIND, x + 174, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_WIND <> 0 Then

                        If .INT2_ELEMAC_WIND > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(185).Draw(x + 174, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_WIND, x + 174, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(185).Draw(x + 174, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_WIND, x + 174, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                    'holy
                    If .INT2_ELEMC_HOLY <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(186).Draw(x + 211, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_HOLY, x + 211, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_HOLY <> 0 Then

                        If .INT2_ELEMAC_HOLY > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(186).Draw(x + 211, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_HOLY, x + 211, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(186).Draw(x + 211, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_HOLY, x + 211, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                    'dark
                    If .INT2_ELEMC_DARK <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(187).Draw(x + 248, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_DARK, x + 248, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_DARK <> 0 Then

                        If .INT2_ELEMAC_DARK > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(187).Draw(x + 248, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_DARK, x + 248, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(187).Draw(x + 248, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_DARK, x + 248, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                    'phantom
                    If .INT2_ELEMC_PHANTOM <> 0 Then

                        If mode = Globals.DrawingMode.Normal Then
                            Libs.GameInter.Image(188).Draw(x + 285, y + 386, z)
                        ElseIf mode = Globals.DrawingMode.Text Then
                            DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMC_PHANTOM, x + 285, y + 386, Color.White, Color.Black, z)
                        End If

                    End If

                    If .INT2_ELEMAC_PHANTOM <> 0 Then

                        If .INT2_ELEMAC_PHANTOM > 0 Then

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(188).Draw(x + 285, y + 411, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText("+" & .INT2_ELEMAC_PHANTOM, x + 285, y + 411, Color.White, Color.Black, z)
                            End If

                        Else

                            If mode = Globals.DrawingMode.Normal Then
                                Libs.GameInter.Image(188).Draw(x + 285, y + 436, z)
                            ElseIf mode = Globals.DrawingMode.Text Then
                                DirectX.ProFont9.DrawBorderText(.INT2_ELEMAC_PHANTOM, x + 285, y + 436, Color.White, Color.Black, z)
                            End If

                        End If

                    End If

                End With

            End If

        End Sub

        Private Sub EquipmentWindow_InterfaceMouseEvent(ByRef type As Mouse.mMouseVars.MouseInputType, ByRef e As System.Windows.Forms.MouseEventArgs, ByRef InterfaceItem As Windows.mWindows.GUIObj) Handles EquipmentWindow.InterfaceMouseEvent

        End Sub

        Private Sub EquipmentWindow_MouseEvent(ByRef type As Mouse.mMouseVars.MouseInputType, ByRef e As System.Windows.Forms.MouseEventArgs) Handles EquipmentWindow.MouseEvent

            'Game.PlayerInputMouseCheck(type, e)

            If GUI.MouseDragItem.mOrigin <> EvoLib.Protocol.ItemLocation.CommisionMerchant And GUI.MouseDragItem.mOrigin <> EvoLib.Protocol.ItemLocation.Storage Then

                If type = Mouse.MouseInputType.MouseMove Then

                    For i As Integer = 0 To 12

                        If EquipSlots(i).rRect.Contains(e.X, e.Y) Then
                            If Not GUI.MouseDragItem.HasMouseDragItem Or EquipSlots(i).itemtype = GUI.MouseDragItem.MouseDragItemDesc.info.Base.BYTE_TYPE Then

                                HoverSlot = i

                                If EquipSlots(i).isSet Then
                                    GameWindow.SetItemTooltip(EquipSlots(i).item.info)
                                Else
                                    GameWindow.HideTooltip()
                                End If

                                Exit Sub

                            End If
                        End If

                    Next

                    HoverSlot = -1
                    GameWindow.HideTooltip()

                ElseIf type = Mouse.MouseInputType.MouseClick Then

                    If HoverSlot >= 0 Then

                        If GUI.MouseDragItem.HasMouseDragItem Then

                            If GUI.MouseDragItem.MouseDragItemDesc.info.Base.BYTE_TYPE = EquipSlots(HoverSlot).itemtype Then

                                With EquipSlots(HoverSlot)

                                    Dim Packet As EvoLib.Protocol.Packet
                                    Packet.Username = Globals.sUsername
                                    Packet.PacketType = EvoLib.Protocol.GamePacketType.ChangeItemLocation
                                    Packet.PacketOpCode = EvoLib.Protocol.PacketOpCode.Notify

                                    Dim struct As EvoLib.Protocol.ItemLocationInfo

                                    .item = GUI.MouseDragItem.MouseDragItemDesc
                                    .isSet = True

                                    struct.INT_ID = .item.info.INT_ID
                                    struct.location = EquipSlots(HoverSlot).slottype

                                    If struct.location = EvoLib.Protocol.ItemLocation.EquipArmor Then

                                        Player.ShapeInfo.INT_ARMORSHAPE = GUI.MouseDragItem.MouseDragItemDesc.info.Base.INT_SHAPE
                                        Player.ShapeInfo.INT_ARMORCOL = GUI.MouseDragItem.MouseDragItemDesc.info.INT_ALPHACOL
                                        Player.CalcAnim(True, True)

                                    ElseIf struct.location = EvoLib.Protocol.ItemLocation.EquipWeapon Then

                                        Player.ShapeInfo.INT_WEAPONSHAPE = GUI.MouseDragItem.MouseDragItemDesc.info.Base.INT_SHAPE
                                        Player.CalcAnim(True, True)

                                    ElseIf struct.location = EvoLib.Protocol.ItemLocation.EquipHelmet Then

                                        Player.ShapeInfo.INT_HEADSHAPE = GUI.MouseDragItem.MouseDragItemDesc.info.Base.INT_SHAPE
                                        Player.CalcAnim(True, True)

                                    ElseIf struct.location = EvoLib.Protocol.ItemLocation.EquipTorch Then
                                        Player.ShapeInfo.BOOL_HASLIGHT = True

                                    End If

                                    ClientSock.SendData(EvoLib.Protocol.MakePacket(Packet, struct, Globals.Crypto))

                                    GUI.MouseDragItem.RemoveMouseDragItem()

                                End With

                            Else

                                GUI.MouseDragItem.ReturnMouseDragItem()
                                GUI.MouseDragItem.RemoveMouseDragItem()

                            End If

                        Else

                            If EquipSlots(HoverSlot).isSet Then

                                GUI.MouseDragItem.SetMouseDragItem(EquipSlots(HoverSlot).item, Inventory.mInventoryGrid, EquipSlots(HoverSlot).slottype, 0, 0, 0, 0, True)
                                EquipSlots(HoverSlot).isSet = False

                                Select Case EquipSlots(HoverSlot).slottype

                                    Case EvoLib.Protocol.ItemLocation.EquipArmor
                                        Player.ShapeInfo.INT_ARMORSHAPE = 0
                                        Player.CalcAnim(True, True)

                                    Case EvoLib.Protocol.ItemLocation.EquipHelmet
                                        Player.ShapeInfo.INT_HEADSHAPE = -1
                                        Player.CalcAnim(True, True)

                                    Case EvoLib.Protocol.ItemLocation.EquipWeapon
                                        Player.ShapeInfo.INT_WEAPONSHAPE = -1
                                        Player.CalcAnim(True, True)

                                    Case EvoLib.Protocol.ItemLocation.EquipTorch
                                        Player.ShapeInfo.BOOL_HASLIGHT = False

                                End Select

                            End If
                        End If
                    End If
                End If
            End If

            'GameWindow.GameWin_MouseEvent(type, e)

        End Sub

        Public Sub ToggleEquipmentWindow()

            If IsVisible Then

                Windows.RemoveWindow(EquipmentWindow)

            Else

                Windows.AddWindow(EquipmentWindow, Windows.WindowType.Normal)

            End If

            IsVisible = Not IsVisible

        End Sub

        Public Sub Reset()

            For i As Integer = 0 To 12

                EquipSlots(i).isSet = False

            Next

        End Sub

        Private Sub HideEquip_Click() Handles HideEquip.Click
            ToggleEquipmentWindow()
        End Sub
    End Module

End Namespace